#ifndef __LASER_H
#define __LASER_H

#include <stdint.h>
#include "adc.h"
#include "kalman.h"

// #define ADC_BUFFER_SIZE     8

typedef struct _laser_t
{
    // uint16_t adc_buffer[ADC_BUFFER_SIZE];
    const uint16_t *adc_buffer; // 指向全局ADC缓冲区
    int adc_buffer_size;        // 全局ADC缓冲区大小
    int adc_split_count;        // 全局ADC缓冲区分割时的激光数量(一个ADC对应几个激光)
    int adc_split_offset;       // 全局ADC缓冲区分割时的激光偏移量(这个激光是这个ADC对应的第几个, 范围是0~adc_split_count)
    int ave_count;

    float k_param; // 激光线性关系k值
    float b_param; // 激光线性关系b值

    float dist;

    Kalman_s kal;    
} laser_t;

typedef struct _laser_init_t
{
    // uint16_t adc_buffer[ADC_BUFFER_SIZE];
    const uint16_t *adc_buffer;
    int adc_buffer_size;
    int adc_split_count;
    int adc_split_offset;

    float k_param;
    float b_param;
} laser_init_t;

typedef struct _laser_t *laser_handle_t;

// void laser_adc_split(uint32_t *laser_adc, laser_handle_t laser[], int count);

void laser_init(laser_handle_t laser, const laser_init_t *init);
float laser_get_dist(laser_handle_t laser);

extern laser_handle_t shooter_laser;
extern laser_handle_t chassis_laser1;

#endif /* !__LASER_H */